//
//  ViewController.m
//  16-AutomaticallyAdjusts
//
//  Created by mafeng on 16/8/4.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "ViewController.h"
#define kTableViewCell @"reuse"
@interface ViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.automaticallyAdjustsScrollViewInsets = NO;

    // 如果是sb的cell不要注册!!!!!!!
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCell];
    cell.textLabel.text = @"呵呵";
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"呵呵");
    // 根据indexpath获取cell
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    NSLog(@"%@", cell.textLabel.text);
    // 根据cell获取indexpath
    NSIndexPath *index = [tableView indexPathForCell:cell];
    
}
// 当触发segue
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSLog(@"%@", sender); // sender是cell
    UITableViewCell *cell = sender;
    // 将值传到目标页面
    segue.destinationViewController.title = cell.textLabel.text;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
